package com.cjj.stop_thread;

/**
 * @ClassName StopThread_02
 * @Date 2021/07/17 18:15:37
 * @Created by ccc-j
 * @email ccc-ju@outlook.com
 */
public class StopThread_02 {
    public static void main(String[] args) {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    try {
                        Thread.sleep(20);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("我是子线程:" + i);
                }
            }
        });
        thread.setDaemon(true);
        thread.start();
        for(int i = 0; i < 30; i++){
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("我是主线程:" + i);
        }
        System.out.println("主线程执行完毕----");
    }
}
